#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#define limit 1000000007

using namespace std;

int C2(int n)
{
    return n * (n - 1) / 2;
}

int main(int argc, char const *argv[])
{
    int bits[10086] = { 0 };
    long long result;
    int n, *arr, *p1, *p2;
    int i, j;
    scanf("%d", &n);
    arr = new int[n];
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
        bits[arr[i]]++;
    }
    
    result = 0;
    for (i = 0; i <= 5000; i++)
    {
        if (bits[i] == 0) continue;
        if (bits[i] >= 2) 
            result += C2(bits[i]) * C2(bits[2 * i]), result %= limit;
        
        for (j = i + 1; j <= 5000; j++)
        {
            result += bits[i] * bits[j] * C2(bits[i + j]); 
            result %= limit;
        }
    }   
    printf("%lld", result);
    return 0;
}
